<?php

	require("includes/functions.php");

	$uid = checkSession();
	if (empty($_POST['searchId'])){
		$searchId = $uid;
	}
	else{
		$searchId = $_POST['searchId'];
	}
	$post = nl2br(addslashes($_POST['post']));

	echo $query = "INSERT INTO posts_table (post,userId,dateCreated,postToId)
					VALUES ('$post', $uid, now(), $searchId)";
										
	mysql_query($query) or die(mysql_error());

	if ($uid != $searchId){
		redirect("viewProfile.php?id={$searchId}");
	}
	else{
		redirect("profile.php");
	}
?>